import pandas as pd
import folium as fm
from folium.plugins import MarkerCluster
import geopandas as gpd
import branca as br
from branca.element import Template, MacroElement
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_10428\2798937669.py in <module>
1 import pandas as pd
----> 2 import folium as fm
3 from folium.plugins import MarkerCluster
4 import geopandas as gpd
5 import branca as br
ModuleNotFoundError: No module named 'folium'
Import the data located at this link. It has information on Tech Institutes’ total vacancies, total applicants, total entrants, and total enrolled. Moreover, the institutes are geolocated.
Variable |
Description |
|---|---|
cod_mod |
institute code |
ltimoden_metaattencion |
total vacancies |
accountdeid_applicant_processadm |
total applicants |
summation_flaging |
total entrants |
sumaden_flagregistered |
total enrolled |
nlat_ie |
latitude |
nlong_ie |
longitude |
Use this shapefile to generate a Choropleth map of the total institutes’ vacancies by the department. Use the overlay function (link and JN) to intersect institutes dataset with shapefiles. You can follow this code:
data = pd.read_csv(r'../../_data/institutos1.csv')
data_geo = gpd.GeoDataFrame(data, crs = "EPSG:4326",
geometry=gpd.points_from_xy(data.nlong_ie,data.nlat_ie))
shp_dpt = gpd.read_file(r"../../_data/INEI_LIMITE_DEPARTAMENTAL\INEI_LIMITE_DEPARTAMENTAL.shp")
intersct_data_geo = gpd.overlay(data_geo, shp_dpt, how = "intersection")
vars_sum = ['ltimoden_metaatencion' , 'cuentadeid_postulante_procesoadm' , 'sumaden_flagingresante', 'sumaden_flagmatriculado']
tot_dpt = intersct_data_geo.groupby(['CCDD'], as_index= False)[vars_sum].sum()
tot_dpt_shp = shp_dpt.merge(tot_dpt, on = 'CCDD')
# government palace coordinates
lat_palacio = -12.0757538
long_palacio = -76.9863174
zoom_start = 5
z = fm.Map(location = [lat_palacio, long_palacio], tiles='cartodbpositron', zoom_start = zoom_start)
fm.Choropleth(
geo_data=tot_dpt_shp,
data=tot_dpt,
columns=['CCDD', 'ltimoden_metaatencion'],
key_on="feature.properties.CCDD",
fill_color="YlOrRd",
fill_opacity=0.8,
line_opacity=0.2,
legend_name="Total vacancies",
smooth_factor=0,
Highlight= True,
line_color = "#0000",
overlay=True,
nan_fill_color = "White" # fill white missing values
).add_to(z)
z
Make this Notebook Trusted to load map: File -> Trust Notebook